home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0037_Show HEX Byte as string.pas < prev    next >
Pascal/Delphi Source File  |  1993-09-26  |  2KB  |  50 lines

  1. TYPE
  2.      String2 = STRING[2];
  3.      String4 = STRING[4];
  4.      String8 = STRING[8];
  5.  
  6. {*****************************************************************************
  7.  * Function ...... HexB()
  8.  * Purpose ....... To return a byte's hexidecimal representation
  9.  * Parameters .... b          Byte to convert to Hex
  10.  * Returns ....... The hex string equivalent of <b>
  11.  * Notes ......... None
  12.  * Author ........ Martin Richardson
  13.  * Date .......... May 13, 1992
  14.  *****************************************************************************}
  15. FUNCTION HexB( b: BYTE ): String2;
  16. CONST
  17.      HexChar : ARRAY[0..15] OF Char = '0123456789ABCDEF';
  18. BEGIN
  19.      Hexb := HexChar[b SHR 4] + HexChar[b AND $F];
  20. END;
  21.  
  22. {*****************************************************************************
  23.  * Function ...... HexW()
  24.  * Purpose ....... To return a word's hexidecimal representation
  25.  * Parameters .... w          Word to convert to Hex
  26.  * Returns ....... The hex string equivalent of <w>
  27.  * Notes ......... Uses function HexB
  28.  * Author ........ Martin Richardson
  29.  * Date .......... May 13, 1992
  30.  *****************************************************************************}
  31. FUNCTION HexW( w: WORD ): String4;
  32. BEGIN
  33.      HexW := HexB(HI(w)) + HexB(LO(w));
  34. END;
  35.  
  36. {*****************************************************************************
  37.  * Function ...... HexDW()
  38.  * Purpose ....... To return a double-word's hexidecimal representation
  39.  * Parameters .... dw          Double-word to convert to Hex
  40.  * Returns ....... The hex string equivalent of <dw>
  41.  * Notes ......... Uses functions HexB, wHi, and wLo
  42.  * Author ........ Martin Richardson
  43.  * Date .......... May 13, 1992
  44.  *****************************************************************************}
  45. FUNCTION HexDW( dw: LONGINT ): String8;
  46. BEGIN
  47.      HexDW := HexB(HI(wHi(dw))) + HexB(LO(wHi(dw))) +
  48.               HexB(HI(wLo(dw))) + HexB(LO(wLo(dw)))
  49. END;
  50.